package top.kaoshanji.ch03;

import top.kaoshanji.ch03.beans.AgentFinder;
import top.kaoshanji.ch03.beans.SpreadsheetAgentFinder;
import top.kaoshanji.ch03.beans.WebServiceAgentFinder;

/**
 * AgentFinder 工厂方法
 * author kaoshanji
 * ^_^
 * create time 2024/12/14 16:29
 */
public class AgentFinderFactory {

    private static AgentFinderFactory singleton;

    private AgentFinderFactory() {}

    public static AgentFinderFactory getInstance() {

        if (singleton == null) {
            singleton = new AgentFinderFactory();
        }

        return singleton;
    }

    public AgentFinder getAgentFinder(String agentType) {

        AgentFinder finder = null;
        switch (agentType) {
            case "spreadsheet":
                finder = new SpreadsheetAgentFinder();
                break;
            case "webservice":
                finder = new WebServiceAgentFinder();
                break;
            default:
                finder = new WebServiceAgentFinder();
                break;
        }

        return finder;
    }



}
